Create tables between objects

I want to create table(with specified contents) after each object in module where
(Object."IsRequirement" ==true) .I am able to create tables successfully but after first table creation it give me error:"Cannot create an object inside table"
How can I move my obj pointer of loop to the very next object of newly created table.My code is inserting each table after first table and is stuck into endless loop.

Object o =null
Module mod = current
Object objTable = null
bool isreq = false
for o in mod do
{
isreq = o."IsRequirement"
if(isreq === true)
objTable=(o,8,2)
// fill up table contents with certain attribute values
}

MF2G_qaus_qazah - Wed Dec 05 00:55:50 EST 2012

Re: Create tables between objects
SudarshanRao - Wed Dec 05 03:02:36 EST 2012

How are you looping through the table cells? If you are using the variable 'o', then that might lead to problems since it's used in the outer loop.
Try this -

Object o =null
Module mod = current
Object objTable, objRow, objCell
bool isreq = false
for o in mod do
{
isreq = o."IsRequirement"
if(isreq == true)
{
objTable=table(o,8,2)
// fill up table contents with certain attribute values
for objRow in table(objTable) do
{
for objCell in row(objRow) do
objCell."Object Text" = "Test"
}
}
}

Re: Create tables between objects
Tony_Goodman - Wed Dec 05 05:39:00 EST 2012

SudarshanRao - Wed Dec 05 03:02:36 EST 2012
How are you looping through the table cells? If you are using the variable 'o', then that might lead to problems since it's used in the outer loop.
Try this -

Object o =null
Module mod = current
Object objTable, objRow, objCell
bool isreq = false
for o in mod do
{
isreq = o."IsRequirement"
if(isreq == true)
{
objTable=table(o,8,2)
// fill up table contents with certain attribute values
for objRow in table(objTable) do
{
for objCell in row(objRow) do
objCell."Object Text" = "Test"
}
}
}

Better to use a skip list so that your object manipulation is outside of the loop
 

Object o = null
Module m = current
Skip requirements = create
bool isReq = false
Object objTable = null
 
for o in m do
{
    isReq = o."IsRequirement"
        
        if (isReq)
        {
                put(requirements, o, o)
        }
}
 
for o in requirements do
{
        objTable = table(o, 8, 2)
}


Tony Goodman, www.smartdxl.com

Re: Create tables between objects
llandale - Wed Dec 05 12:48:40 EST 2012

Tony_Goodman - Wed Dec 05 05:39:00 EST 2012

Better to use a skip list so that your object manipulation is outside of the loop
 

Object o = null
Module m = current
Skip requirements = create
bool isReq = false
Object objTable = null
 
for o in m do
{
    isReq = o."IsRequirement"
        
        if (isReq)
        {
                put(requirements, o, o)
        }
}
 
for o in requirements do
{
        objTable = table(o, 8, 2)
}


Tony Goodman, www.smartdxl.com

if (isDeleted(o) or table(o) or row(o) or cell(o)) continue

I'd be tempted to store objects in natural order:
  • int Sequencer = 0
  • ..
    • put(requirements, Sequencer++, o)
-Louie